package com.sikaryofficial.common.core.enums;

import cn.hutool.core.text.CharSequenceUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author : qinjinyuan
 * @desc : 店铺数据来源
 * @date : 2023/11/06 16:31
 */
@Getter
@AllArgsConstructor
public enum ArticleSourceEnum {

    /**
     * 数据来源：manual-手工; evaluate-评价
     */
    SYSTEM(1, "爬虫"),
    USER(2, "用户创建"),
    ;
    private final Integer code;
    private final String name;

    public static ArticleSourceEnum getSourceEnum(Integer code) {
        return Arrays.stream(ArticleSourceEnum.values())
                .filter(sourceEnum -> Objects.nonNull(code) && sourceEnum.getCode().equals(code))
                .findFirst().orElse(null);
    }
}
